package com.bdqn.systems.auth;

import com.bdqn.response.Result;
import com.bdqn.response.ResultCode;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author : CP
 * @version: 1.0
 * @program : xinguan-parent
 * @description : 身份验证入口点
 * @date : 2020-12-26 14:24
 **/
@Component
public class MyAuthenticationEntryPoint extends JSONAuthentication implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
        Result error = Result.error(ResultCode.USER_NOT_LOGIN);
        this.WriteJSON(request,response,error);
    }
}
